package com.zqsign.core.key.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.zqsign.core.key.external.KeyPairExternal;
import com.zqsign.core.key.pojo.KeyPairInfo;

/**
* @ClassName 	: KeyPairController 
* @Description 	: 
*
* @Company 		: zqsign
* @author 		: wx 
* @date 		: 2018年2月27日 上午11:35:46 
*/

@RestController
@RequestMapping("/key")
public class KeyPairController {
	
	@Autowired
	private KeyPairExternal keyPairExternal;
	
	@GetMapping("/genKeyPair")
	public KeyPairInfo genKeyPair(@RequestParam(value ="userId",defaultValue = "001")String userId){
		try {
			return keyPairExternal.genKeyPair(userId);
		} catch (Exception e) {
			e.printStackTrace();
		}
		return null;
	}
	
	@GetMapping("/getKeyPair")
	public KeyPairInfo getKeyPair(@RequestParam(value = "orderNum", required = true, defaultValue = "001") String orderNum){
		try {
			return keyPairExternal.getKeyPair(orderNum);
		} catch (Exception e) {
			e.printStackTrace();
		}
		return null;
	}
	
}
